package com.corechina.apex_osswords.controller;


import com.corechina.apex_osswords.common.Response;
import com.corechina.apex_osswords.common.ShiroUtils;
import com.corechina.apex_osswords.common.SysLog;
import com.corechina.apex_osswords.domain.entity.CorePollingPlan;
import com.corechina.apex_osswords.service.ICorePollingPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 巡检计划表 前端控制器
 * </p>
 *
 * @author cc
 * @since 2023-03-10
 */

@Api(tags = "巡检计划管理②")
@RestController
@RequestMapping("/core/pollingPlan")
public class CorePollingPlanController {

    @Autowired
    private ICorePollingPlanService iCorePollingPlanService;

    @ApiOperation("新增")
    @SysLog("新增巡检计划")
    @PostMapping("/add")
    public Response add(@RequestBody CorePollingPlan corePollingPlan) {
        return iCorePollingPlanService.add(corePollingPlan);
    }

    @ApiOperation("删除")
    @SysLog("删除巡检计划")
    @DeleteMapping("/del")
    public Response del(Integer id) {
        return iCorePollingPlanService.del(id);
    }

    @ApiOperation("编辑")
    @SysLog("编辑巡查计划")
    @PutMapping("/update")
    public Response update(@RequestBody CorePollingPlan corePollingPlan) {
        return iCorePollingPlanService.update(corePollingPlan);
    }

    @ApiOperation("列表")
    @GetMapping("/getList")
    public Response getList(Integer abnormal, Integer pollingId, Integer status, String planPersonName, Integer planPerson, Integer isToday, String beginDate, String endDate, Integer pageIndex, Integer pageSize) {
        return iCorePollingPlanService.getList(abnormal, pollingId, ShiroUtils.getSeeAll().equals(1) ? null : ShiroUtils.getEnterpriseId(), status, planPersonName, planPerson, isToday, beginDate, endDate, pageIndex, pageSize);
    }

    @ApiOperation("详情")
    @GetMapping("/getOne")
    public Response getOne(Integer id) {
        return iCorePollingPlanService.getOne(id);
    }
}

